package com.neusoft.databus.policy.dto;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.google.common.collect.Lists;
import com.neusoft.bizcore.web.dto.AbstractAuditDTO;
import com.neusoft.databus.policy.enums.PolicyType;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 策略dto
 *
 * @author naxiang
 */
@Getter
@Setter
@ToString
public class PolicyDTO extends AbstractAuditDTO {

    /**
     *
     */
    private static final long serialVersionUID = -100616532705455282L;
    /**
     * 策略编码
     */
    @NotBlank(message = "策略编码不能为空")
    @Length(max = 255, message = "策略编码不能超过{max}位")
    private String code;
    /**
     * 策略名称
     */
    @ApiModelProperty(value = "策略名称", required = true, position = 1)
    @NotBlank(message = "策略名称不能为空")
    @Length(max = 255, message = "策略名称不能超过{max}位")
    private String name;
    /**
     * 禁用标识
     */
    @ApiModelProperty(value = "禁用标识", required = true, position = 2)
    private boolean disabled = false;
    /**
     * 拓展属性
     */
    @ApiModelProperty(value = "拓展属性", required = false, position = 3)
    @Length(max = 1023, message = "资源连接信息不能超过{max}位")
    private String extendProperty;
    /**
     * 描述
     */
    @ApiModelProperty(value = "描述", required = false, position = 4)
    @Length(max = 1023, message = "描述不能超过{max}位")
    private String description;

    /**
     * 判据。可扩展的误报保护判据 <br />
     * {"frequency": {"interval":"60000","times":"2"}}
     * 目前支持“频次判断法”，在interval间隔（毫秒）内，发生times次，才生成报警事件
     */
    @ApiModelProperty(value = "可扩展的误报保护判据", required = false, position = 5)
    @Length(max = 1023, message = "策略执行频次不能超过{max}位")
    private String criterion;

    /**
     * 事件类型
     */
    @ApiModelProperty(value = "事件类型", required = true, position = 6)
    @Enumerated(EnumType.STRING)
    @NotNull(message = "事件类型不能为空")
    private PolicyType policyType;

    /**
     * 报警事件内容模板
     */
    @ApiModelProperty(value = "报警事件内容模板", required = true, position = 7)
    @NotBlank(message = "报警事件内容模板不能为空")
    @Length(max = 1023, message = "报警事件内容模板不能超过{max}位")
    private String contentTemplate;
    //	/**
    //	 * 事件级别
    //	 */
    //	@ApiModelProperty(value = "事件级别", required = true, position = 8)
    //	@Enumerated(EnumType.STRING)
    //	@NotNull(message = "事件级别不能为空")
    //	private EventPriority eventPriority;
    /**
     * 关联指标表达式
     */
    @ApiModelProperty(value = "关联指标表达式", required = false, position = 8)
    private List<ExpressionDTO> expressions = new ArrayList<>();

    /**
     * 资源编码
     */
    @ApiModelProperty(value = "资源编码", required = true, position = 9)
    @Length(max = 255, message = "资源编码不能超过{max}位")
    private String resourceCode;

    /**
     * 资源绑定关系
     */
    private List<PolicyRefResourceDTO> policyRefResources = Lists.newArrayList();

    /** 联动资源 */
    private List<PolicyRefLinkageDTO> policyRefLinkages = Lists.newArrayList();

}
